import service from "@/utils/request"

import LoginWork from "@/utils/LoginWork" 

// 带入剩料仓材料明细
export interface BringInResidualNinDetailsParms{
    slipDateEnd:string,
    slipDateStart:string,
    slipNo:string,
    slipReason:string,
    type:number
}

export interface BringInResidualNinDetailsTableDateLit{
    slipNo: string,
    slipDate: string,
    slipReason: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    qty: null,
    remark: null,
    mtlNo: null,
    cfmFlag: null | boolean | string
}

export const BringInResidualNinDetails = (parms:BringInResidualNinDetailsParms) => {
    return service.put<any,BringInResidualNinDetailsTableDateLit[]>(`/pcFactorStockQuery/getSurpDetailQuery`,parms)
}

// 剩料仓库明细
export interface RemainingBinDetailsInterface{
    mtlName: string,
    mtlColor: string,
    mtlSpec: null,
    mtlUnit: string,
    stkQty: number,
    qty: null,
    remark: null,
    mtlNo: string,
    companyId: string
}


export const RemainingBinDetails = () => {
    return service.get<any,RemainingBinDetailsInterface[]>('/pcFactorStockQuery/getSurpTempQuery')
}

// 剩料原因
export const SurplusCause = () => {
    return service.post<any,any>(`/back/getSlReasonQuery?type=${'I'}`)
}

// 库存材料
export interface InventoryMaterialInquiryParms {
    mtlColor:string,
    mtlName:string,
    mtlNo:string,
    mtlType:string,
    pageNum:number,
    pageSize:number,
    stkFlag:number
}

export interface InventoryMaterialInquiryQuerDate{
    mtlNo: string,
    mtlName: string,
    mtlUnit: string,
    mtlColor: string,
    stkQty: number
}

export interface InventoryMaterialInquiryInterface{
    total?:number
    dtos:InventoryMaterialInquiryQuerDate[]
}

export const InventoryMaterialInquiry = (parms:InventoryMaterialInquiryParms) => {
    return service.put<any,InventoryMaterialInquiryInterface>(`/back/getMtlSub`,parms)
}

export interface date{
    code:number,
    data:string,
    message:string
}

// 转入待入库新增
export const TransferToPendingStorage = (parms:any) => {
    return LoginWork.put<any,date>('/pcFactorStockQuery/surpTempAdd',parms)
}

// 待入剩料仓材料删除
export const MaterialToBeRemovedFromRemainingBin = (mtlNo:string) => {
    return LoginWork.post<any,date>(`/pcFactorStockQuery/surpTempDelete?mtlNo=${mtlNo}`)
}

// 转剩料仓材料明细删除
export const RemovedFromRemainingBin = (mtlNo:string,slipNo:string) => {
    return LoginWork.post<any,date>(`/pcFactorStockQuery/surpTempDelete?mtlNo=${mtlNo}&slipNo=${slipNo}`)
}

// 指令资料查询
export interface LotNoQueryParms{
    lotNo:string,
    mtlName:string,
    pageNum:number,
    pageSize:number,
    style:string,
    typeNo:string
}

export interface LotNoQueryInterface{
    total?:number
    dtos:LotNoQueryInterfaceDtos[]
}

interface LotNoQueryInterfaceDtos{
    lotNo: string,
    seqNo: number,
    partName: string,
    segment: number,
    mtlTypeNo: string,
    mtlType: string,
    mtlNo: string,
    mtlColor: string,
    mtlName: string,
    mtlSpec: null,
    mtlUnit: string,
    ttlUsage: number,
    stkQty: number
}

export const LotNoQuery = (parms:LotNoQueryParms) => {
    return service.put<any,LotNoQueryInterface>(`/pcFactorStockQuery/surpLotMtlQuery`,parms)
}

// 转剩料仓
export const TurnOverTheBin = (mtlNo:string,slipReason:string) => {
    return LoginWork.post<any,date>(`/pcFactorStockQuery/surpDetailAdd?mtlNo=${mtlNo}&slipReason=${slipReason}`)
}